<template>
  <view>
    <button @click="chooseLocation">选择位置</button>
    <view> {{ postion.address }}</view>
    <view> {{ postion.lonlat }}</view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      postion: {},
    };
  },
  onLoad() {
    let that = this;
    uni.$on("getPostion", function (data) {
      if (data.postion) {
        console.log("index", data.postion);
        that.postion = data.postion;
      }
    });
  },
  methods: {
    // 打开地图选择位置
    chooseLocation() {
      uni.navigateTo({
        url: "/pages/index/selectLocation",
      });
    },
  },
};
</script>